
#pragma once

typedef struct searchpath_s
{
	char    filename[MAX_OSPATH];
	struct pack_s  *pack;          // only one of filename / pack will be used
	struct searchpath_s *next;
} searchpath_t;

extern searchpath_t    *com_searchpaths;

// on disk
typedef struct dpackfile_s
{
	char name[56];
	int filepos, filelen;
} dpackfile_t;

typedef struct dpackheader_s
{
	char id[4];
	int dirofs;
	int dirlen;
} dpackheader_t;

// in memory
typedef struct pack_s
{
	char filename[MAX_OSPATH];
	int handle;
	int numfiles;
	dpackfile_t *files;
} pack_t;

void FS_Init (char *path);
char *FS_SkipPath (char *pathname);
void FS_StripExtension (char *in, char *out);
void FS_FileBase (char *in, char *out);
void FS_DefaultExtension (char *path, char *extension);
BOOL FS_CreateDirectory (char *path);

extern int com_filesize;
extern char com_gamedir[MAX_OSPATH];

int FS_OpenFile (char *filename, int *hndl);
int FS_FOpenFile (char *filename, FILE **file);
void FS_CloseFile (int h);
byte *FS_LoadFile (char *path, class QALLOCATORBASE *allocator);

void FS_LoadGame (void);
void FS_UnloadGame (void);

// these are our enumeration functions
void FS_EnumerateMaps (void);
void FS_EnumerateDemos (void);
void FS_EnumerateSaves (void);
void FS_EnumerateContent (void);

// and this one runs an auto-completion
char *FS_AutoCompleteList (struct key_autotab_t *at, char *partial);
